import requests


class EmployeeApi(object):

    @classmethod
    def add_emp(cls, headers, body):
        """
        新增员工
        :param headers: 请求头 -  包含令牌
        :param body: 新增员工请求体
        :return: 响应对象
        """
        url = "http://ihrm2-test.itheima.net/api/sys/user"
        resp = requests.post(url, headers=headers, json=body)
        return resp

    @classmethod
    def modify_emp(cls, id, headers, body):
        """
        修改员工
        :param id: 员工id
        :param headers: 请求头
        :param body: 请求体
        :return: 响应对象
        """
        url = "http://ihrm2-test.itheima.net/api/sys/user" + "/" + id
        resp = requests.put(url, headers=headers, json=body)
        return resp

    @classmethod
    def query_emp(cls, id, headers):
        """
        查询员工接口
        :param id: 员工id
        :param headers: 请求头
        :return: 响应对象
        """
        url = "http://ihrm2-test.itheima.net/api/sys/user" + "/" + id
        resp = requests.get(url, headers=headers)
        return resp

    @classmethod
    def delete_emp(cls, id, headers):
        """
        删除员工接口
        :param id: 员工id
        :param headers: 请求头
        :return: 响应对象
        """
        url = "http://ihrm2-test.itheima.net/api/sys/user" + "/" + id
        resp = requests.delete(url, headers=headers)
        return resp



